package UTS.model;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Vincentius HMK
 */
public class DokumenTableModel extends AbstractTableModel {

    String columNames[] = {"Nomor", "Perihal", "Asal", "Penerima", "Letak", "Tanggal Diterima", "Status"};
    private ArrayList<Dokumen> data;

    public DokumenTableModel() {
        data = new ArrayList<Dokumen>();
       
    }

    public DokumenTableModel(ArrayList<Dokumen> data) {
        this.data = data;
    }

    public int getRowCount() {
        return getData().size();
    }

    public int getColumnCount() {
        return columNames.length;
    }

    @Override
    public String getColumnName(int col) {
        return columNames[col];
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Dokumen temp = getData().get(rowIndex);
        if (columnIndex == 0) {
            return temp.getNomor();
        } else if (columnIndex == 1) {
            return temp.getPerihal();
        } else if (columnIndex == 2) {
            return temp.getAsal();
        } else if (columnIndex == 3) {
            return temp.getPenerima();
        } else if (columnIndex == 4) {
            return temp.getLetak();
        }else if (columnIndex == 5) {
            return temp.getTanggalDiterima();
        }else {
            return temp.getStatusDokumen();
        }
    }

    public ArrayList<Dokumen> getData() {
        return data;
    }

    public void setData(ArrayList<Dokumen> data) {
        this.data = data;
    }

    public Dokumen getDokumen(int index) {
        return (Dokumen) data.get(index);
    }
}
